package com.fourpigeon.controller;

import com.fourpigeon.dao.UserDao;
import com.fourpigeon.domain.*;
import com.fourpigeon.service.BlogGetService;
import com.fourpigeon.service.BlogService;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.fourpigeon.service.UserService;

import java.net.http.HttpRequest;
import java.time.LocalDateTime;
//
@RestController
@RequestMapping("/user")
public class UserController{
    @Autowired
    private UserService userService;
    @Autowired
    private UserDao userDao;
    @Autowired
    private BlogGetService blogGetService;


    @PostMapping("/login/wechat")
    public Result loginWechat(@RequestParam String code,@RequestParam String userName){return userService.loginWechat(code,userName);}

    @GetMapping("/of/me")
    public Result getMe(){
        return userService.getMe();
    }

    @GetMapping("/of/{userId}")
    public Result getOther(@PathVariable Long userId){
        return userService.getOther(userId);
    }

    @PostMapping("/info/update")
    public Result updateInfo(@RequestBody UserInfo user){
        return userService.updateInfo(user);
    }

    @GetMapping("/agreeBlog/{blogType}/{userId}/{startId}")
    public Result getUserAgrees(@PathVariable Short blogType, @PathVariable Long userId, @PathVariable Long startId){
        return blogGetService.getUserAgrees(blogType, userId, startId);
    }

    @GetMapping("/dailyBlog/{userId}/{startId}")
    public Result getUserDailies(@PathVariable Long userId, @PathVariable Long startId){
        return blogGetService.getUserDailies(userId, startId);
    }

    @GetMapping("/dealBlog/{userId}/{startId}")
    public Result getUserDeals(@PathVariable Long userId, @PathVariable Long startId){
        return blogGetService.getUserDeals(userId, startId);
    }

    @GetMapping("/practiceBlog/{userId}/{startId}")
    public Result getUserPractices(@PathVariable Long userId, @PathVariable Long startId){
        return blogGetService.getUserPractices(userId, startId);
    }
    @PostMapping("/issue")
    public Result sendIssue(@RequestBody Issue issue){
        return userService.sendIssue(issue);
    }

    @PostMapping("/logout/wechat")
    public Result logOut(@RequestParam String authorization){return userService.logOut(authorization);}

    @GetMapping("/dailyBlog/{startId}")
    public Result getMyDailyPage(@PathVariable Long startId){return userService.getMyDailyPage(startId);}

    @GetMapping("/dealBlog/{startId}")
    public Result getMyDealPage(@PathVariable Long startId){return userService.getMyDealPage(startId);}

    @GetMapping("/agreeBlog/{blogType}/{startId}")
    public Result getMyAgreePage(@PathVariable Short blogType,@PathVariable Long startId){return userService.getMyAgreePage(blogType,startId);}

    @GetMapping("/practiceBlog/{startId}")
    public Result getMyPracticePage(@PathVariable Long startId){return userService.getMyPracticePage(startId);}
}
